<?php
/* @var $this RobotController */
/* @var $model Robot */

$this->breadcrumbs=array(
	'Robots'=>array('index'),
	'Manage',
);

if(0==strcmp(Yii::app()->user->name,"admin")){ 
	$this->menu=array(
		array('label'=>'客户端管理', 'url'=>array('admin')),
		array('label'=>'添加客户端', 'url'=>array('create')),
	);
}

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#robot-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Robots</h1>


<!-- search-form -->
<?php if(0==strcmp(Yii::app()->user->name,"admin")){ 
 $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'robot-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,

	'columns'=>array(
		'id',
		'name',
		array(
		'name'=>'taskid',
		'value'=>'Task::model()->find("id=".$data->taskid)->title',
		),
		
		array(
		'name'=>'lasttime',
		'value'=>'"<div title=\'$data->lasttime\' rel=\"tooltip\">".(ceil((time() - strtotime($data->lasttime))/60) > 30?"<div class=disconnection></div>维护中...":"<div class=connection></div>发送中...")."</div>"',
		'type'=>'raw'
		), 
		array(
			'class'=>'CButtonColumn',
		),
	),
)); 
} else {
 $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'robot-grid',
	'dataProvider'=>$model->search(),
	'columns'=>array(
		'id',
		'name',
		array(
		'name'=>'stat',
		'value'=>'"<div>".(ceil((time() - strtotime($data->lasttime))/60) > 30?"<div class=disconnection></div>维护中...":"<div class=connection></div>发送中...")."</div>"',
		'type'=>'raw'
		), 
		array(
		'name'=>'lasttime',
		'value'=>'$data->lasttime',
		),
		 
	),
)); 
}?>
